<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="button" @click="add" value="添加">
        <input type="button" @click="dev" value="减少">
        <li v-for="(item,index) in arr">
            {{index+1}}{{item}}
        </li>
        <h2 v-for="tem in vegetables">
            {{tem.name}}
        </h2>
    </div>
    <script src="./vue.js"></script>
    <script>
        var ap = new Vue({
            el: "#app",
            data: {
                arr: ["北京", "上海", "广州", "深圳"],
                vegetables: [{
                    name: "西兰花"
                }, {
                    name: "鸡蛋"
                }]
            },
            methods: {
                add: function() {
                    this.vegetables.push({
                        name: "西兰花炒蛋"
                    });
                },
                dev: function() {
                    this.vegetables.shift();
                }
            }
        })
    </script>
</body>

</html>